package it.gestoreContratti.gui.frames;

import it.gestoreContratti.entity.Specifica;
import it.gestoreContratti.gui.panels.ProrogaSpecificaPanel;
import it.gestoreContratti.gui.panels.VisualizzaSpecificheContrattoPanel;

import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;

public class ProrogaSpecificaFrame extends JFrame {

	/**
	 * 
	 */
	private static final long serialVersionUID = 7398935146016431787L;
	private JPanel contentPane;
	private VisualizzaSpecificheContrattoPanel pannello;

	
	/**
	 * Create the frame.
	 */
	public ProrogaSpecificaFrame(VisualizzaSpecificheContrattoPanel p, Specifica spec) {
		addWindowListener(new WindowAdapter() {
			@Override
			public void windowClosing(WindowEvent e) {
				pannello.refresh();
			}
		});
		this.pannello = p;
		setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
		setBounds(100, 100, 450, 300);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		GridBagLayout gbl_contentPane = new GridBagLayout();
		gbl_contentPane.columnWidths = new int[]{0, 0};
		gbl_contentPane.rowHeights = new int[]{0, 0};
		gbl_contentPane.columnWeights = new double[]{1.0, Double.MIN_VALUE};
		gbl_contentPane.rowWeights = new double[]{1.0, Double.MIN_VALUE};
		contentPane.setLayout(gbl_contentPane);
		
		ProrogaSpecificaPanel prorogaSpecificaPanel = new ProrogaSpecificaPanel(p.getContratto(), p.getDatabaseController(),spec);
		GridBagConstraints gbc_prorogaSpecificaPanel = new GridBagConstraints();
		gbc_prorogaSpecificaPanel.fill = GridBagConstraints.BOTH;
		gbc_prorogaSpecificaPanel.gridx = 0;
		gbc_prorogaSpecificaPanel.gridy = 0;
		contentPane.add(prorogaSpecificaPanel, gbc_prorogaSpecificaPanel);
	}

}
